import http from '@/utils/http';
import type {MutationTree, ActionTree, GetterTree} from 'vuex'
import type {State} from '@/store'
import {addWord} from "@/utils/db";
import type {Word} from "@/types/words";




export interface WordsState {
    words: Word[]
}

const state: WordsState = {
    words:[]
}


const mutations: MutationTree<WordsState> = {
    // 创建状态，更新状态
    updateWords(state, payload) {
        state.words = payload
        // addWord(state.words)
    },
    clearWords(state, payload) {
        state.words = []
    },

};
const actions: ActionTree<WordsState, State> = {
    // 异步提交状态，动作
    translation(context, payload) {
        return http.get('/', payload)
    },
};
// 对状态的值 进行计算
const getters: GetterTree<WordsState, State> = {};
export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}
